#include <my_head.h>
int main(int argc, char const *argv[])
{
    pid_t pid = fork();
    if(-1 == pid){
        ERR_LOG("fork error");
    }else if(0<pid){
        #if 0
        if(-1 == wait(NULL)){
            ERR_LOG("wait error");
        }
        printf("这是父进程 回收子进程资源成功\n");
        #else
        int wstatus = 0;
        if(-1 == wait(&wstatus)){
            ERR_LOG("wait error");
        }
        if(WIFEXITED(wstatus)){
            printf("子进程是正常结束的 退出状态值为:[%d]\n",WEXITSTATUS(wstatus));
        }else if(WIFSIGNALED(wstatus)){
            printf("子进程是被信号中断结束的 中断子进程的信号的编号为:[%d]\n",WTERMSIG(wstatus));
        }
        #endif
        sleep(12);
    }else if(0 == pid){
        printf("这是子进程 %d\n",getpid());
        sleep(12);
        printf("这是子进程 %d 退出\n",getpid());
        exit(200);
    }
    return 0;
}
